library(dplyr)
library(lubridate)
library(ggplot2)
library(stringr)
library(scales)

Sys.setlocale("LC_TIME", "English")

setwd("C:/Users/k.takeda/Dropbox/My_Research_Papers/Abomb/Takeda_Yamagishi/Replication Package JPE/code/R")
pop <- read.csv("../../data/raw data/newspaper/predicted_population.csv", fileEncoding = "UTF-8")

pop$Year <- as.Date(pop$Year)
View(pop)
str(pop$Year)
colnames(pop)
head(pop$Year)

pop$Year_label <- format(pop$Year, "%b %Y")
pop$Year_label <- paste0(str_sub(month.abb[month(pop$Year)], 1, 3), " ", year(pop$Year))

p <- ggplot(pop, aes(x = Year, y = Predicted.population..thousands.)) +
  geom_line(color = "black", linewidth = 1) +
  geom_point(color = "black", size = 3) +
  scale_y_continuous(
    breaks = seq(0, 400, by = 100), 
    limits = c(0, 400)
  ) +
  scale_x_date(
    date_breaks = "6 months",
    date_labels = "%b %Y"
  ) +
  labs(
    x = "Projection Year",
    y = "Predicted Population (thousands)"
  ) +
  theme_minimal(base_size = 13) 

ggsave("../../output/figure/Predicted Population.png", plot = p)
